package com.example.mountainwalker.mapper;

import com.example.mountainwalker.entity.ManagerInfo;
import com.example.mountainwalker.entity.ScenicSpotInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface ScenicSpotMapper {
    @Select("SELECT * FROM ScenicSpot")
    List<ScenicSpotInfo> getScenicSpotList();

    @Select("SELECT * FROM ScenicSpot WHERE ScenicSpotID = #{id}")
    ScenicSpotInfo getScenicSpotById(Integer id);

    @Delete("DELETE FROM ScenicSpot WHERE ScenicSpotID = #{id}")
    int deleteScenicSpotById(Integer id);

    @Insert("INSERT INTO ScenicSpot(ScenicSpotID, ScenicAreaName, RegionID, ScenicSpotLevel, " +
            "Altitude, ComprehensiveDifficultyIndex, ScenicSpotDescription, " +
            "ScenicSpotLink, CreationTime, UpdateTime) " +
            "VALUES(#{scenicSpotID}, #{scenicAreaName}, #{regionID}, #{scenicSpotLevel}, " +
            "#{altitude}, #{comprehensiveDifficultyIndex}, #{scenicSpotDescription}, " +
            "#{scenicSpotLink}, #{creationTime}, #{updateTime})")
    int addScenicSpot(ScenicSpotInfo scenicSpotInfo);

    @Update("UPDATE ScenicSpot SET ScenicAreaName=#{scenicAreaName}, " +
            "RegionID=#{regionID}, ScenicSpotLevel=#{scenicSpotLevel}, " +
            "Altitude=#{altitude}, ComprehensiveDifficultyIndex=#{comprehensiveDifficultyIndex}, " +
            "ScenicSpotDescription=#{scenicSpotDescription}, ScenicSpotLink=#{scenicSpotLink}, " +
            "UpdateTime=#{updateTime} WHERE ScenicSpotID=#{scenicSpotID}")
    int updateScenicSpot(ScenicSpotInfo scenicSpotInfo);

    @Select("select * from Manager where AdminName= #{name}")
    ManagerInfo getManagerInfoByName(String name);
}